export class CurrencyConverterService {
  usdToForeignRates = {
    USD: 1,
    EUR: 0.74,
    CNY: 6.09,
  };

  currencies = ["USD", "EUR", "CNY"];

  // /**
  //  * @typedef {{USD: number;EUR: number;CNY: number;}} ForeignRates
  //  */
  /**
   * @param {number} amount
   * @param {'USD' | 'EUR' | 'CNY'} inCurr
   * @param {'USD' | 'EUR' | 'CNY'} outCurr
   * @returns {number}
   */
  convert(amount, inCurr, outCurr) {
    return (
      (amount * this.usdToForeignRates[outCurr]) /
      this.usdToForeignRates[inCurr]
    );
  }
}
